<template>
  <div class="flow-applist">
    <div class="template-list">
      <div v-if="myAppList.length > 0">
        <div
          class="card-item"
          v-for="(item, index) in myAppList"
          :key="index"
          @click="openService(item)"
        >
          <div class="item-icon">
            <div class="app-icon">
              <img :src="showAppIcon(index)" class="icon-img" />
            </div>
          </div>
          <div class="item-cont">
            <div class="item-title">
              {{ item.projectName }}
            </div>
            <div class="item-desc">
              {{ item.clientDescribe }}
            </div>
          </div>
        </div>

        <div
          class="card-item"
          @click="addService()"
        >
          <div class="item-icon">
            <div class="app-icon">
              <img src="http://data.linesno.com/default_add.png" class="icon-img" />
            </div>
          </div>
          <div class="item-cont">
            <div class="item-title">
              创建应用 
            </div>
          </div>
        </div>

      </div>

      <div v-else>
          <div class="item-blank" @click="applicationManger()" > <i class="el-icon-s-promotion"></i> 未创建应用，创建一个</div>
      </div>

    </div>
  </div>
</template>

<script>
// import { getDesignFormJson } from "@/api/cloud/flow/approver";
import { getApplicationList } from "@/api/Application";

export default {
  name: "index",
  data() {
    return {
      myAppList: [],
    };
  },
  created(){
    this.getApplicationList();
  } ,
  methods: {
    applicationManger(){
      this.$router.push({ path: '/build/genSeedProject' })
    },
    showAppIcon(index) {
      let number = index % 10;
      return require("@/asserts/images/deskicon/" + (number + 2) + ".png");
    },
    //租户过滤获取所有应用列表
    getApplicationList() {
      getApplicationList().then(res => {
        this.myAppList = res.data;
      });
    },
    // 打开服务
    openService(item) {
      var projectId = item.id;

      var toPath = "/build/overview/" + projectId;
      this.$router.push({path: toPath});
    },
    addService(){
      var toPath = "/build/genSeedProject" ; 
      this.$router.push({path: toPath});
    } 
  },
};
</script>

  <style scoped lang="scss">
.flow-applist {
  overflow-x: hidden;
  height: auto;
  padding: 0px 10px 10px 10px;
  background-color: #f7f9fa;

  .template-list {
    margin-right: -30px;
    min-height: 270px;

    .item-blank{
      margin: auto;
      text-align: center;
      padding-top: 140px;
      font-size: 14px;
      cursor: pointer;
    }

    .card-item {
      float: left;
      width: calc(25% - 18px);
      margin-right: 16px;
      margin-top: 16px;
      padding: 9px 16px;
      background: #fff;
      border-radius: 3px;
      cursor: pointer;
      display: flex;
      align-items: center;

      .item-cont {
        overflow: hidden;
      }

      .item-title {
        font-size: 12px;
        color: #000000;
        font-family: "PingFangSC-Medium";
      }

      .item-desc {
        font-size: 12px;
        line-height: 20px;
        color: rgba(25, 31, 37, 0.56);
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
      }

      .item-icon {
        margin-right: 8px;
      }

      .app-icon {
        width: 32px;
        height: 32px;
        position: relative;

        .icon-img {
          width: 100%;
          height: 100%;
          border-radius: 5px;
        }
      }
    }
  }
}
</style>


